﻿﻿<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<%
	String path = request.getContextPath();
%>
<div id="page-wrapper">
        <div id="page-inner">
            <div class="row">
                <div class="col-md-12">
                   <div class="panel panel-default">
                        <div class="panel-heading">密码修改</div>
                        <div class="panel-body">
							<form method="post" id="myForm">						
                    <div class="form-body pal">
                       <div class="form-group">
							<div style="width: 350px; position: relative; top: 20px;">
								<label for="newPassword1">新密码</label> <input
								type="password" class="form-control" id="newPassword1"
								placeholder="新密码" name="newPassword1">
							</div>
						</div>
                        <div class="form-group">
							<div style="width: 350px; position: relative; top: 20px;">
								<label for="newPassword2">确认新密码</label> <input
								type="password" class="form-control" id="newPassword2"
								placeholder="确认新密码" name="newPassword2">
							</div>

						</div>
                         
                    	<button type="button" class="btn btn-primary btn-lg btn-block" id="updatepassword" style="width: 200px; position: relative;top: 20px;">确认修改</button>
                    	</div>
                    
                	</form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<script type="text/javascript">
$(function(){
	$("#updatepassword").on('click',function(){
		if($("#newPassword1").val()==""||$("#newPassword1").val()==null){
			swal("提交失败", "密码不能为空", "error");
			return false;
		}else if($("#newPassword1").val().length<6){
			swal("提交失败", "密码不能小于6位", "error");
			return false;
		}else{
			if(($("#newPassword1").val())!=($("#newPassword2").val())){
				swal("提交失败", "两次输入的密码不一致，请从新输入", "error");
				return false;
			}
		}
		$.ajax({
	            type: "POST",
	            url: "<%=path %>/updateManagerPassword",
	            data: $("#myForm").serialize(),
	            success: function(data,status,xhr){
	                if(data.isSuccess==1){
						swal({ 
							  title: "提交成功", 
							  text: "密码修改成功，请重新登录", 
							  type: "success",
							},
							function(){
								window.location.href="<%=path %>/j_spring_security_logout";
							});
					}else{
						swal("提交失败", data.msg, "error");
					}
	            },
	            error: function (textStatus){
	            	swal("提交失败", "服务器异常", "error");
	            }
			});
	});
})
	
</script>

